import falcon

from WebBackend.middleware.virtualWorldGate_Chuche import login_require
from WebBackend.store.ConfigurationStore import ConfigurationStore
from WebBackend.utils.readFile import read_file_async
import App_setting as setting

@falcon.before(login_require)
class ExecuteLogAPI:
    def __init__(self, config=None):
        self.config_store: ConfigurationStore = config

    async def on_get(self, req, resp: falcon.Response):
        data = await read_file_async(setting.path.file_datalog, 'list')
        resp.media = [item.rstrip() for item in data]
